# -*- coding: utf-8 -*-
"""
Created on Tue Jul  9 20:46:57 2024

@author: Volta
"""

user_input = float(input("What number do you want to find the cube root of?"))
acc = int(input("how many decimal places accuracy do you want?"))

if user_input > 0:
    low = 0
    high = user_input

if user_input < 0:
    high = 0
    low = user_input
    
g = (high+low)/2

print("my guess is", g)

while abs(g**3 - user_input) >= .1**acc:
    if g**3 < user_input:
        low = g
    else:
        high = g
    g = (low+high)/2
    print (g)

g = round(g, acc)

print ("your cube root is approximately", g)